<template>
	<view>
		<view class="detail-box">

			<view class="cu-form-group">
				<view class="title">仓库编号：</view>
				<input class="inpt1" name="input" v-model="NowSelectGoods.StoreCode"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">仓库名称：</view>
				<input class="inpt1" name="input" v-model="NowSelectGoods.StoreName"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">所属机构:</view>
				<view class="inpt1">
					<input type="text" placeholder="点击获取" :value="NowSelectGoods.BranchName" disabled="true"
					 data-target="StoreModal" @tap="showModal" />
					<view class="cu-modal" :class="modalName=='StoreModal'?'show':''">
						<view class="cu-dialog">
							<view class="cu-bar bg-white justify-end">
								<view class="content">请选择机构</view>
								<view class="action" @tap="hideModal">
									<text class="cuIcon-close text-red"></text>
								</view>
							</view>
							<view class="padding-xl">
								<view class="StoreListWrap">
									<view v-for="(item,index) in StoreList" :key="item.StoreID" @tap="selectStore(index)">{{item.BranchName}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">是否停用：</view>
				<!-- <input class="inpt" name="input" disabled="false"></input> -->
				<picker @change="PickerChange5" :value="index5" :range="picker5">
					<view class="picker">
						{{index5>-1?picker5[index5]:'点击选择'}}
					</view>
				</picker>
			</view>
		</view>
		<view class="cu-form-group">
			<!-- <button class="cu-btn  stop text-white" @tap="AddBillOrder">提交修改</button> -->
			<input class="inpt" name="input" disabled="true"></input>
			<button class="cu-btn  stop text-white" @tap="Add_StoreMessage(isChange==1)">{{isChange==1?"提交修改":"提交新增"}}</button>
		</view>
	</view>
</template>
<script>
	import * as Api from '@/syApis/syDa/syDa.js'
	export default {
		data() {
			return {
				//选择的商品
				NowSelectGoods: {
					StoreName: "",
					StoreCode: "",
					IsStop:false,
					BranchName:"",
					BranchID:"",
				},
				picker5:[
					"否","是"
				],
				index5:0,
				modalName:null,
				StoreList:[],
				isChange:false
			}
		},
		created() {
			this.Get_BranchMessage();
		},
		onLoad(options) {
			this.isChange = options.isChange;
             if(options.isChange==1){
				  uni.setNavigationBarTitle({
				  	title:"修改仓库档案"
				  });
				  this.NowSelectGoods = JSON.parse(options.StoreItem);
				  
				  this.index5 = this.NowSelectGoods.IsStop ? 1:0
			 }else{
				 uni.setNavigationBarTitle({
				 	title:"新增仓库档案"
				 })
			 }
		},
		methods: {
			//选择机构
			selectStore(index){
				this.NowSelectGoods.BranchName = this.StoreList[index].BranchName;
				this.NowSelectGoods.BranchID = this.StoreList[index].BranchID;
				this.modalName = null;
			},
			//显示弹框
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(){
				this.modalName = "";
			},
			//赠品选择
			PickerChange5(e) {
				if (e.detail.value == -1) {
					this.index5 = 0
				} else {
					this.index5 = e.detail.value
				}
				// this.index5 = e.detail.value
				this.NowSelectGoods.IsStop = this.index5==0?false:true;
			},
			switchChange(e) {
				let value = e.target.value
				let that = this
				this.$set(this.treatmentStatu, 'checked', value) // 将点击改变的状态赋给treatmentStatu.checked
				if (value && !this.havePromise) {
					uni.showModal({
						title: '提示',
						content: '是否停用',
						success: function(res) {
							if (res.confirm) {
								that.$emit('changePage', 1)
								console.log('用户点击确定')
							} else if (res.cancel) {
								that.$set(that.treatmentStatu, 'checked', false) // 手动修改switch的状态，视图会同步更新
								console.log('用户点击取消');
							}
						}
					});
				}
			},
			//获取仓库
			Get_BranchMessage() {
				let data = {
					Filter: ""
				}
				this.picker2 = [];
				var that = this;
				Api.Get_BranchMessage(data, function(res) {
					if (res.state) {
						if (res.data.ErrorMsg == "获取登录信息失败") {
							Api.showTip("登录超时");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							let responseData = res.data.ResultMsg;
							that.StoreList = res.data.ResultMsg;
						}
					} else {

					}
				});
			},
			PickerChange2(e) {
				console.log(e)
				this.index2 = e.detail.value;
				// this.NowSelectGoods.BranchID = this.StoreList[e.detail.value].BranchID;
			},
			Changer_StoreMessage(){
				let CreateID = uni.getStorageSync("UserCode");
				let Save_M_Data_Json = {
					StoreCode: this.NowSelectGoods.StoreCode,
					StoreName: this.NowSelectGoods.StoreName,
					BranchID: this.NowSelectGoods.BranchID,
					IsStop: this.NowSelectGoods.IsStop+"",
					CreateID: CreateID,
					ChangeID :this.NowSelectGoods.ChangeID,
					StoreID:this.NowSelectGoods.StoreID
				};
				let data = {
					Save_M_Data_Json: JSON.stringify(Save_M_Data_Json)
				}
				var _this = this;
				Api.Update_StoreMessage(data, function(res) {
					if (res.state) {
						if (res.data.TipsMsg == 'OK') {
							Api.showTip("更新成功");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							console.log(res);
						}
				
					} else {
						Api.showTip("服务器开小差了");
					}
				})
			},
			//新增仓库档案
			Add_StoreMessage(isChange) {
				if(isChange){
					this.Changer_StoreMessage();
					return;
				}
				let CreateID = uni.getStorageSync("UserCode");
				let Save_M_Data_Json = {
					StoreCode: this.NowSelectGoods.StoreCode,
					StoreName: this.NowSelectGoods.StoreName,
					BranchID: this.NowSelectGoods.BranchID,
					IsStop: this.NowSelectGoods.IsStop+"",
					CreateID: CreateID

				};
				let data = {
					Save_M_Data_Json: JSON.stringify(Save_M_Data_Json)
				}
				var _this = this;
				Api.Add_StoreMessage(data, function(res) {
					if (res.state) {
						if (res.data.TipsMsg == 'OK') {
							Api.showTip("新增成功");
						} else if (res.data.ErrorMsg != "") {
							Api.showTip(res.data.ErrorMsg);
						} else {
							console.log(res);
						}

					} else {
						Api.showTip("服务器开小差了");
					}
				})
			},

			//折扣改变事件
			changeZk(e) {
				console.log(e);
			},

			//计算折扣后商品价格
			computPrice(item) {
				item.PFPrice = item.PFPrice * item.Qty * (item.Discount / 100) * (1 + item.Tax / 100);
				return item;
			}
		}
	}
</script>
<style>
	button::after {
		border: none;
		padding: 0px;
	}

	.headerGd {
		position: fixed;
		left: 0px;
		top: 0upx;
		width: 100%;
		background: url(../../static/gooslitHeaderBg.jpg);
	}

	.header {
		position: relative;
		height: 100upx;
		line-height: 100upx;
		text-align: center;
		color: #FFF;


	}

	.header .back {
		width: 40upx;
		height: 40upx;
		background: url(../../static/back.png) no-repeat;
		position: absolute;
		left: 10px;
		top: 15px;
		background-size: 20px;
	}

	.title-padding {
		height: var(--status-bar-height);
		background: $bb-bg-color;
		box-sizing: content-box;
	}

	body::-webkit-scrollbar {
		display: none;
	}

	page {
		width: 100%;
		height: 100%;
		padding-bottom: 55px;
	}

	.goodWrapper {
		width: 100%;
		height: 100% !important;
		display: flex;
		flex-direction: column;
	}

	.goodHeader {
		width: 100%;
		display: table;
		position: fixed;
		left: 0px;
		top: var(--status-bar-height);
		z-index: 99999;
	}

	.goodHeaderContaint {
		width: 100%;
		height: 50px;
		line-height: 50px;
		position: relative;
		text-align: center;
		background: url(../../static/gooslitHeaderBg.jpg);
		color: #FFF;
		font-size: 18px;
		background-size: 100%;

	}

	.goodHeaderContaint .pd {
		display: inline-block;
		position: absolute;
		margin-left: 10px;
		top: 30upx;
		left: 0px;
		font-size: 14px;
		width: 40upx;
		height: 40upx;
		background: url(../../static/back.png) no-repeat;
		background-size: 100%;
	}

	button::after {
		border: none;
		padding: 0px;
	}

	.goodHeaderContaint .options {
		position: absolute;
		right: 0px;
		top: 10px;
		width: 80px;
		display: flex;
		text-align: right;
	}

	.goodHeaderContaint .setting {
		width: 30px;
		height: 30px;
		background: url(../../static/setting.png) no-repeat;
		background-size: 30px;
		border: none;
		margin-left: 90upx;

	}

	.goodHeaderContaint .addGoods {
		width: 25px;
		height: 25x;
		background: url(../../static/addicon.png) no-repeat;
		background-size: 100%;
		border: none;
	}

	.goodContainer {
		flex: 1;
		/* margin-top: calc(var(--status-bar-height) + 50px); */
		padding-bottom: 110upx;

	}

	.goodContainer .searchInput {
		width: 100%;
		height: 40px;
		line-height: 40px;
		background: #FFF;
		display: flex;
		flex-direction: row;
		position: fixed;
		background: #FFF;
		z-index: 99999;
	}

	.goodContainer .searchInput .goodType {
		background: #f1f2f7;
		border-radius: 20px;
		height: 50rpx;
		line-height: 50rpx;
		color: #9699a2;
		padding-left: 10px;
		padding-right: 10px;
		font-size: 12px;
		margin-top: 6px;
		margin-left: 10px;
	}

	.goodContainer .searchInput .goodFilter {
		flex: 1;
		display: flex;
		background: #eff2fb;
		border-radius: 20px;
		height: 50rpx;
		line-height: 50rpx;
		margin-top: 6px;
		box-sizing: border-box;
		margin-left: 10px;
		margin-right: 5px;
		overflow: hidden;
	}

	.goodContainer .searchInput .goodFilter .searchOption {
		flex: 1;
		height: 50rpx;
		line-height: 50rpx;
		font-size: 22upx;
		color: #9699a2;
	}

	.goodContainer .searchInput .goodFilter .searchBt {
		height: 50rpx;
		line-height: 50rpx;
		width: 120rpx;
		border-radius: 0;
		background: #0081FF;
		color: #FFF;
		font-size: 24rpx;
	}

	.goodContainer .searchInput .searchOptions {
		width: 70px;
		height: 40px;
		display: flex;
		flex-direction: row;
		padding-top: 7.5px;
	}

	.goodContainer .searchInput .searchOptions .giveSong {
		width: 25px;
		height: 25px;
		background: url(../../static/lysong.png) no-repeat;
		padding: 0px;
	}

	.goodContainer .searchInput .searchOptions .getPicture {
		width: 25px;
		height: 25px;
		background: url(../../static/sm.png) no-repeat;
		padding: 0px;
	}

	.goodContainer .scroll-Y {
		margin-top: 40px;
	}

	.goodContainer .goodsItem {
		width: 100%;
		display: flex;
		flex-direction: row;
		box-sizing: border-box;
		padding-left: 15upx;
		padding-right: 30upx;
		border-top: 1px solid #ebebeb;
		padding-top: 10upx;
		padding-bottom: 10upx;
	}

	.goodContainer .goodsItem .checkboxContainer {
		width: 40px;
		height: 80px;
		text-align: center;
	}

	.goodContainer .goodsItem .checkboxContainer .checkboxTemp {
		width: 20px;
		height: 20px;
		margin-top: 30px;
		border: 1upx solid #ccc;
	}

	.goodContainer .goodsItem .checkboxContainer .checkboxTemp.checkboxTempActive {
		background: url(../../static/order/checkBoxIcon.png) no-repeat;
		background-size: 40upx 40upx;
	}

	.goodContainer .goodsItem .goodsImg {
		width: 180upx;
		height: 180upx;
		display: inline-block;
		border: 1px solid #ebebeb;
	}

	.goodContainer .goodsItem .goodInfo {
		display: flex;
		flex-direction: column;
		padding-left: 16upx;
		flex: 1;
		overflow: hidden;
	}

	.goodContainer .goodsItem .goodInfo .goodName {
		height: 60upx;
		line-height: 60upx;
		font-size: 32upx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		position: relative;

	}

	.goodContainer .goodsItem .goodInfo .goodName button {
		width: 120upx;
		font-size: 22upx;
		height: 50upx;
		padding-left: 0rpx;
		padding-right: 0rpx;
		line-height: 50upx;
		background: #0081FF;
		color: #FFF;
		position: absolute;
		right: 0upx;
		top: 5upx;
		text-align: center;
	}

	.goodContainer .goodsItem .goodInfo .priceWrap {
		display: flex;
		height: 120upx;
		line-height: 120upx;
		flex-direction: column;
	}

	.goodContainer .goodsItem .goodInfo .price {
		flex: 2;
		height: 120upx;
		line-height: 120upx;
		color: #969897;
		display: flex;
		box-sizing: border-box;
		padding-right: 15upx;
	}

	.goodContainer .goodsItem .goodInfo .price view {
		flex: 1;
	}

	.goodContainer .goodsItem .goodInfo .addGood {
		flex: 1;
		text-align: center;
	}

	.goodContainer .goodsItem .goodInfo .addGood button {
		width: 50upx;
		height: 50upx;
		background: url(../../static/addgoodIcon.png) no-repeat;
		background-size: 100%;
		padding: 0px;
		margin-top: 25upx;
	}

	.goodContainer .goodsItem .goodInfo .price text {
		height: 40upx;
		line-height: 40upx;
	}

	.goodContainer .goodsItem .goodInfo .price view {
		height: 40upx;
		line-height: 40upx;
		display: flex;

	}

	.goodContainer .goodsItem .goodInfo .price view input {
		flex: 1;
		border: 1upx solid #ccc;
		padding-left: 5upx;
	}

	.goodContainer .goodsItem .goodInfo .price .rightPrice {
		text-align: right;
	}

	.goodsCount {
		width: 100%;
		height: 100upx;
		line-height: 100upx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		background: #f1f1fb;
		text-align: center;
		z-index: 9999;
		display: flex;
		flex-direction: row;
	}

	.goodsCount view {
		text-align: center;
		flex: 1;
		box-sizing: border-box;
		border-right: 1upx solid #ccc;
		line-height: 100upx;
	}

	.goodsCount view:last-child {
		border-right: none;
	}

	.goodsCount.goodCar {
		display: flex;
		flex-direction: row;
	}

	.goodsCount.goodCar .carIcon {
		width: 100upx;
		height: 100upx;
		text-align: center;
		position: relative;
	}

	.goodsCount.goodCar .carIcon image {
		width: 50upx;
		height: 50upx;
		margin-top: 25upx;
		margin-left: 25upx;
	}

	.goodsCount.goodCar .carIcon text {
		position: absolute;
		min-width: 25upx;
		height: 30upx;
		right: 10upx;
		top: 18upx;
		line-height: 30upx;
		background: red;
		border-radius: 25upx;
		padding-left: 8upx;
		padding-right: 8upx;
		color: #FFF;
		font-size: 20upx;
	}

	.goodsCount.goodCar .priceAll {
		flex: 4;
	}

	.goodsCount.goodCar .sureBt {
		flex: 2;
		background: #68e4e6;
		color: #FFF;
	}

	.goodsCount.goodCar .carInfo {
		position: fixed;
		bottom: 100upx;
		min-height: 100upx;
		background: #FFF;
		width: 100%;
	}

	.goodsCount.goodCar .carTitle {
		height: 60upx;
		line-height: 60upx;
		display: flex;
	}

	.goodsCount.goodCar .carTitle text {
		flex: 1;
		text-align: left;
		padding-left: 30upx;
		padding-right: 30upx;
		background: #68e4e6;
		color: #FFF;
	}

	.goodsCount.goodCar .carTitle text:last-child {
		text-align: right;
	}

	.goodsCount.goodCar .carList {
		max-height: 448upx;
		overflow: auto;
	}

	.goodsCount.goodCar .carList .carItem {
		width: 100%;
		display: flex;
		flex-direction: row;
		height: 100upx;
		line-height: 100upx;
		padding-top: 10upx;
		padding-bottom: 10upx;
	}

	.goodsCount.goodCar .carList .carItem image {
		width: 60upx;
		height: 60upx;
		margin-top: 20upx;
		margin-left: 10upx;
		margin-right: 30upx;
	}

	.goodsCount.goodCar .carList .carItem .goodInfo {
		flex: 2;
		display: flex;
		flex-direction: column;
	}

	.goodsCount.goodCar .carList .carItem .goodInfo text {
		flex: 1;
		line-height: 50upx;
		text-align: left;
	}

	.goodsCount.goodCar .carList .carItem .numOptions {
		flex: 1;
		box-sizing: border-box;
		padding-top: 20upx;
		padding-left: 30upx;
		padding-right: 30upx;
	}

	.goodsCount.goodCar .carList .carItem .numOptions .numOptionsWrap {
		width: 100%;
		height: 50upx;
		border: 1px solid #68e4e6;
		display: flex;
		border-radius: 10upx;
	}

	.goodsCount.goodCar .carList .carItem .numOptions .subtraction,
	.add {
		width: 100upx;
		height: 50upx;
		line-height: 50upx;
		font-size: 40upx;
		box-sizing: border-box;
	}

	.goodsCount.goodCar .carList .carItem .numOptions .subtraction {
		border-top-left-radius: 10upx;
		border-bottom-left-radius: 10upx;
		border-right: 1px solid #68e4e6;
	}

	.goodsCount.goodCar .carList .carItem .numOptions input {
		height: 50upx;
		line-height: 50upx;
		font-size: 20upx;
		box-sizing: border-box;
		padding: 0upx;
	}

	.goodsCount.goodCar .carList .carItem .numOptions .add {
		border-top-right-radius: 10upx;
		border-bottom-right-radius: 10upx;
		border-left: 1px solid #68e4e6;
	}

	.allGoodsType {
		width: 100%;
		height: calc(100% - 50px);
		background: #FFF;
		position: fixed;
		top: 90px;
		left: 0px;
		z-index: 99999;
	}

	.allGoodsType .typeTitle {
		width: 100%;
		height: 40px;
		line-height: 40px;
		color: #000;
		padding-left: 15px;
		border-bottom: 1px solid #ebebeb;
		box-sizing: border-box;
		padding-right: 15px;
		font-size: 32upx;
	}

	.allGoodsType .typeTitle .pulljt {
		display: inline-block;
		float: right;
		transform: rotate(90deg);
		-ms-transform: rotate(90deg);
		/* IE 9 */
		-moz-transform: rotate(90deg);
		/* Firefox */
		-webkit-transform: rotate(90deg);
		/* Safari 和 Chrome */
		-o-transform: rotate(90deg);
	}

	.allGoodsType .typeItem {
		display: block;
		width: 100%;
		height: 40px;
		line-height: 40px;
		border-bottom: 1px solid #ebebeb;
		margin-left: 15px;
		padding-left: 5px;
		font-size: 28upx;

	}
	.padding-xl {
		padding: 10px;
	
	}
	
	.padding-xl .searchStore button {
		font-size: 14px;
		color: #FFF;
		padding-left: 8px;
		padding-right: 8px;
		height: 35px;
		line-height: 35px;
		border-radius: 0px;
		border-top-right-radius: 5px;
		border-bottom-right-radius: 5px;
		text-align: center;
		background: rgba(124, 170, 216, 1);
	}
	
	.padding-xl .StoreListWrap {
		height: 250px;
		overflow: auto;
	}
	
	.padding-xl .StoreListWrap view {
		height: 40px;
		line-height: 40px;
		text-align: left;
		border-bottom: 1px solid #CCC;
		padding-left: 8px;
	}
	.padding-xl .GoodsListWrap{
		height: 250px;
		overflow: auto;
	}
	.padding-xl .GoodsListWrap view{
		height: 40px;
		padding:3px;
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 5px;
	}
	.padding-xl .GoodsListWrap view image{
		width: 40px;
		height: 40px;
	}
	.padding-xl .GoodsListWrap view text{
		flex: 1;
		height: 40px;
		text-align: left;
		padding-left: 10px;
		box-sizing: border-box;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
	.inpt1{
		flex: 1;
		text-align: right;
	}
	.stop{
		background: rgba(124, 170, 216,1) !important;
	}
</style>
